package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {

    /**
     * 根据类型和时间查询总数
     */
    @Select("select count(distinct user_id) from tb_log where log_time=#{logTime} and type=#{type} ")
    Integer queryByLogTimeAndType(@Param("logTime") String logTime, @Param("type") String type);

    /**
     * 根据时间查询总数
     */
    @Select("select count(distinct user_id) from tb_log where log_time=#{logTime}")
    Integer queryByLogTime(String logTime);

    /**
     * 查询次日留存
     */
    @Select("select count(distinct user_id) from tb_log where log_time=#{today} and user_id in ( \n " +
            "\t select user_id from tb_log where log_time=#{yesterday}  and type='0102' \n" +
            ")")
    Integer queryNumRetention1d(@Param("today") String today,@Param("yesterday") String yesterday);
}
